<?php
/**
 * Created by PhpStorm.
 * User: mac
 * Date: 19/12/21
 * Time: 19:42
 */

namespace app\admin\controller;

use app\common\bean\ListMap;
use app\common\bean\StoreCashBean;
use app\common\controller\AdminController;
use app\common\enum\StoreCashStatusEnum;
use app\common\manage\StoreCashManage;
use app\common\utils\ExitJsonUtil;

class StoreCash extends AdminController
{
    /**
     * 商家提现订单
     * @throws \Exception
     */
    public function storeCashList(){
        $listMap = new ListMap();
        $listMap->setData($this->getParams);
        $listMap->setParameter(StoreCashBean::$storeId,0);
        $storeCashMap = StoreCashManage::getInstance()->getPaginatorList($listMap);
        $this->assign("storeCashList",$storeCashMap->getList());
        $this->assign("currentPage",$storeCashMap->getCurrentPage());
        $this->assign("totalCount",$storeCashMap->getTotalCount());
        $this->assign('statusSelect',StoreCashStatusEnum::getArrayName());
        return $this->fetch();
    }

    /**
     * 审核提现订单
     * @throws \Exception
     */
    public function reviewStoreCash(){
        $storeCashBean = new StoreCashBean();
        if(request()->post()){
            $storeCashBean->setData($this->postParams);
            $result = StoreCashManage::getInstance()->reviewStoreCash($storeCashBean);
            ExitJsonUtil::getInstance()->exitData($result);
        }
        $storeCashBean->setData($this->getParams);
        $storeCashBean = StoreCashManage::getInstance()->getInfo($storeCashBean);
        $statusSelect =[StoreCashStatusEnum::TRYSUCCESS => StoreCashStatusEnum::getName(StoreCashStatusEnum::TRYSUCCESS),StoreCashStatusEnum::TRYFAIL => StoreCashStatusEnum::getName(StoreCashStatusEnum::TRYFAIL)];
        $this->assign('storeCash',$storeCashBean->getData());
        $this->assign('statusSelect',$statusSelect);
        return $this->fetch();
    }
}